var jwt = require('jsonwebtoken');
const jwtTokenSecret = 'Dtt123456!';
module.exports = {
  /** 
   * data: {***}
   * time: 如60，"2 days"，"10h"，"7d"
   */
  getToken: (data, time = '30 days') => {
    const token = jwt.sign(data, jwtTokenSecret, { expiresIn: time });

    return token;
  },
  verifyToken: (token) => {
    let data = null;
    if (token) {
      data = jwt.verify(token, jwtTokenSecret);
    }
    return data;
  }
}